package com.goodsogood.union.auth.util;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


@Component("ossConfiger")
public class OssConfiger {
	
	@Value("${oss.img.upload.path}")
    private String fileUploadPath;

	@Value("${oss.access.key.id}")
    private String accessKeyId;

	@Value("${oss.access.key.secret}")
    private String accessKeySecret;

	@Value("${oss.img.bucket.name}")
    private String bucketName;

	@Value("${oss.endpoint}")
    private String endpoint;

	@Value("${oss.img.website}")
    private String imgAccessWebSite;

	@Value("${oss.tmp.upload.path}")
	private String tmpFileUploadPath;

	@Value("${oss.tmp.bucket.name}")
	private String tmpBucketName;

	@Value("${oss.tmp.website}")
    private String tmpAccessWebSite;

	public String getFileUploadPath() {
		return fileUploadPath == null ? "" : fileUploadPath;
	}

	public String getAccessKeyId() {
		return accessKeyId == null ? "" : accessKeyId;
	}

	public String getAccessKeySecret() {
		return accessKeySecret == null ? "" : accessKeySecret;
	}

	public String getBucketName() {
		return bucketName == null ? "" : bucketName;
	}

	public String getEndpoint() {
		return endpoint == null ? "" : endpoint;
	}

	public String getImgAccessWebSite() {
		return imgAccessWebSite == null ? "" : imgAccessWebSite;
	}
	
	public String getEnableAccessUrl(String key) {
		if(StringUtils.isBlank(key)) {
			return "";
		}
		return getImgAccessWebSite() + "/" + key;
	}

	public String getTmpBucketName() {
		return tmpBucketName == null ? "" : tmpBucketName;
	}

	public String getTmpAccessWebSite() {
		return tmpAccessWebSite == null ? "" : tmpAccessWebSite;
	}

	public String getTmpFileUploadPath() {
		return tmpFileUploadPath == null ? "" : tmpFileUploadPath;
	}
}
